<%@ page import="com.shamar.blog.entity.BlogUser" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!--输出,条件,迭代标签库-->
<%@ page isELIgnored="false" %>
<%!
    public String username;
    public BlogUser M;
    public Boolean islogin;
%>
<%
    M = (BlogUser) session.getAttribute("currentBlogUser");
    if (M!=null){ username = M.getUsername();
        islogin = true;}
    else{
        islogin=false;
    }
%>
<!DOCTYPE html>
<body>
<head>
    <link rel='stylesheet' href='css/blog_edit.css' type='text/css' media='all' />
    <link rel="shortcut icon " type="images/x-icon" href="me.ico">
    <title>编辑博客--${blog.title}</title>
</head>
<style type="text/css">

</style>
<nav class="navbar navbar-inverse bg-inverse navbar-toggleable-md">
    <div class="container">
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
                data-target="#navbarsContainer" aria-controls="navbarsExampleContainer" aria-expanded="false"
                aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
            <!-- Website Logo -->
            <a href="/community/index" title="程序员博客社区">
                <img src="images/logo.png" alt="程序员博客社区">
            </a>

        <div class="collapse navbar-collapse" id="navbarsContainer">

            <ul class="navbar-nav mr-auto">
                <li class="nav-item">
                    <a class="nav-link" href="javascript:void(0)" >最新 <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="javascript:void(0)" >最热</a>
                </li>
                <form class="form-inline mt-2 mt-md-0">
                    <input class="form-control mr-sm-2" type="text" placeholder="搜索" id="indexkeyword" th:value="${keyword}">
                    <a href="javascript:void(0)" class="btn btn-outline-secondary my-2 my-sm-0" id="indexsearch"><i class="fa fa-search" aria-hidden="true"></i></a>
                </form>
            </ul>
            <%--登录与否界面会不一样--%>
        <c:if test="<%= islogin%>">
            <div class="row" >
                    <span style="color: white;vertical-align: center">欢迎您,<%= username%></span>
                    <a class="btn btn-outline-success my-2 my-sm-0" href="/community/push_blog">写博客</a>
                    <a class="btn btn-outline-info my-2 my-sm-0" href="/community/articles_list?o=3">我的博文</a>
                    <a class="btn btn-outline-primary " href="#">我的收藏</a>
                    <a class="btn btn-outline-danger my-2 my-sm-0" id="logout" href="#">退出</a>
            </div>
        </c:if>
            <%--登录注册--%>
            <c:if test="<%= !islogin%>">
            <div>
                <a href="/user/userlogin" class="btn btn-outline-success my-2 my-sm-0" type="submit">登录</a>
                <a href="/admin/register" class="btn btn-outline-success my-2 my-sm-0" type="submit">注册</a>
            </div>
            </c:if>
        </div>

    </div>
</nav>
<!-- Page Content -->
<div class="container blog-content-container">
    <c:if test="${nologin==null && noPermission==null}">
        <div class="row">

            <!-- Blog Entries Column -->
            <div class="col-md-8">
                <!-- Blog Post -->
                <div class="card mb-4">
                    <div class="card-block">
                        <input type="hidden" name="id" value="${blog.id}" id="blogId">
                        <input value="${blog.title}"  type="text" class="form-control" placeholder="请填写博客标题"  id="title" name="title" maxlength="50">

                            <%--<textarea class="blog-textarea" placeholder="请填写博客摘要"  id="summary" name="summary"  maxlength="300"></textarea>--%>

                        <hr>
                        <textarea id="md" data-provide="markdown" data-hidden-buttons="cmdImage" name="content">${blog.content}
                        </textarea>

                        <hr>
                    </div>

                </div>

            </div>

            <!-- 右侧栏目 -->
            <div class="col-md-4">

                <!-- 文章目录 -->
                <div class="card ">
                    <h5 class="card-header"><i class="fa fa-file-image-o" aria-hidden="true"></i> 图片上传</h5>
                    <div class="card-block">
                        <div class="row mt-1">
                            <div  class="col-lg-12">


                                <form  enctype="multipart/form-data"  id="uploadformid"  >
                                    <input type="file" name="file" accept="image/png,image/gif,image/jpeg" id="file">
                                    <button class="btn btn-primary float-right"  type="button" id="uploadImage" >插入</button>

                                </form>

                            </div>
                        </div>
                    </div>

                </div>
                <!-- 图片上传 -->
                <div class="card ">
                    <h5 class="card-header"><i class="fa fa-cog" aria-hidden="true"></i> 博客设置</h5>
                    <div class="card-block">
                        <div class="row mt-1">
                            <div  class="col-lg-12">
                                标签： 					<input type="text" class="form-control form-control-tag" value="python,coding,hh">
                            </div>
                        </div>
                        <div class="row mt-1">
                            <div  class="col-lg-12">
                                分类：				<select id="catalogSelect" class="form-control form-control-chosen" data-placeholder="请选择" >
                                <c:forEach items="${allCategory}" var="category" varStatus="currentCategory">
                                    <option value="${category.id}" <c:if test="${category.id == blog.categoryId}">selected</c:if>>${category.categoryName}</option>
                                </c:forEach>
                            </select>
                            </div>
                        </div>
                        <div class="row mt-1">
                            <div  class="col-lg-12">
                                <button class="btn btn-primary float-right" id="submitBlog" >发布</button>
                            </div>
                        </div>

                    </div>

                </div>
            </div>

        </div>
    </c:if>
    <c:if test="${nologin!=null}">
        <div class="col-md-8">
            未登录状态下不能进行博客编辑
        </div>
    </c:if>
    <c:if test="${noPermission!=null}">
        <div class="col-md-8">
            非发布者不能进行编辑
        </div>
    </c:if>

    <!-- /.row -->

</div>
<!-- /.container -->


<footer class="blog-footer bg-inverse" data-th-fragment="footer">
    <a id="goToTop" href="#">
        <i class="fa fa-chevron-up fa-3x" aria-hidden="true"></i>
    </a>
    <div class="container">
        <p class="m-0 text-center text-white">© 2019 <a href="">shamar fang</a></p>
    </div>

    <!-- JavaScript -->
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/jquery.form.min.js"></script>
    <script src="js/jquery.tagsinput.min.js"></script>
    <script src="js/tether.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/nprogress.js"></script>
    <script src="js/thinker-md.vendor.min.js"></script>
    <script src="js/chosen.jquery.js"></script>
    <script src="js/toastr.min.js"></script>
    <script src="js/cropbox.js"></script>
    <script src="js/catalog-generator.js"></script>
    <script src="js/main.js"></script>
    <script src="js/userlogout.js"></script>
</footer>

<script src="js/userspace/blogedit.js"></script>
<script>
    $(function(){
        // 默认显示
        $(".dropdown-toggle").dropdown('toggle');
    });
</script>
</body>
</html>